#!/bin/bash
# Author: Xun Deng

ds='osdata/'
dt='initrd/'

### etc
mkdir -pm 755 "${dt}etc/ssh/"
cp -p "${ds}etc/ssh/sshd_config" "${dt}etc/ssh/"

mkdir -pm 755 "${dt}etc/default/"
cp -p "${ds}etc/default/locale" "${dt}etc/default/"

mkdir -pm 755 "${dt}etc/systemd/network/"
cp -p "${ds}etc/systemd/resolved.conf" "${dt}etc/systemd/"
cp -p "${ds}etc/systemd/timesyncd.conf" "${dt}etc/systemd/"
cp -p "${ds}etc/systemd/network/20-wired.network" "${dt}etc/systemd/network/"

cp -p "${ds}etc/hostname" "${ds}etc/resolv.conf" "${ds}etc/sysctl.conf" "${dt}etc/"

rm -rf "${dt}etc/update-motd.d" # clean
mkdir -pm 755 "${dt}etc/update-motd.d/"
cp -p "${ds}etc/update-motd.d/00-header" "${dt}etc/update-motd.d/"

### root
rm -rf "${dt}root" # clean
mkdir -pm 700 "${dt}root/"
cp -p "${ds}root/.bashrc" "${ds}root/.profile" "${dt}root/"

### usr
mkdir -pm 755 "${dt}usr/bin/"
cp -p "${ds}usr/bin/ifup" "${dt}usr/bin/"

mkdir -pm 755 "${dt}usr/lib/firmware/"
cp -rp "${ds}usr/lib/firmware/rtl_nic/" "${dt}usr/lib/firmware/"

### change owner and group
chown -R root "${dt}"
chgrp -R root "${dt}"
